/**
 * 路由拦截器
 */
import router from './router'
import store from './store'
router.beforeEach((to, from, next) => {
    console.log(to, from)
    if (to.fullPath === '/login') {
        next()
    } else {
        if (store.getters.token) {
            console.log('store.getters.menuList',store.getters.menuList)
            if (store.getters.menuList.length === 0) {
                store.dispatch('getMenuList').then(() => {
                    next({ ...to, replace: true })
                }).catch(() => {
                    next('/login')
                })
            }
            next()
        } else {
            next('/login')
        }
    }
})